﻿using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;

using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;

namespace PulseOximeterTestApp
{
    public partial class Program
    {
        GTM.Seeed.PulseOximeter sensor = new GTM.Seeed.PulseOximeter(11);

        void ProgramStarted()
        {
            /******************************************************************************************
            Access modules defined in the designer by typing their name:                            
            
            e.g.  button
                  camera1

            Initialize event handlers here.
            e.g. button.ButtonPressed += new GTM.MSR.Button.ButtonEventHandler(button_ButtonPressed);             
            ***************************************************************************************** */

            sensor.Heartbeat += new GTM.Seeed.PulseOximeter.HeartbeatHandler(sensor_Heartbeat);
            sensor.ProbeAttached +=new GTM.Seeed.PulseOximeter.ProbeAttachedHandler(sensor_ProbeAttached);
            sensor.ProbeDetached += new GTM.Seeed.PulseOximeter.ProbeDetachedHandler(sensor_ProbeDetached);
            // Do one-time tasks here
            Debug.Print("Program Started");
        }

        void sensor_ProbeDetached(GTM.Seeed.PulseOximeter sender)
        {
            Debug.Print("pulse oximeter probe detached");
        }

        void sensor_ProbeAttached(GTM.Seeed.PulseOximeter sender)
        {
            Debug.Print("pulse oximeter probe attached");
        }


        void sensor_Heartbeat(GTM.Seeed.PulseOximeter sender, GTM.Seeed.PulseOximeter.Reading reading)
        {
            PulseDebugLED();
            Debug.Print("heartrate: " + reading.PulseRate + " SPO2 " + reading.SPO2 + " signal " + reading.SignalStrength);
        }
    }
}
